<?php /* Smarty version Smarty-3.1.8, created on 2012-05-28 23:18:52
         compiled from "E:\Programy\WebServ\httpd\ekino\admin\templates\sala.tpl" */ ?>
<?php /*%%SmartyHeaderCode:157994fc3ebbc87b899-98634808%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '28a08df0ec503e89ec0a43db206f88e9ab18af29' => 
    array (
      0 => 'E:\\Programy\\WebServ\\httpd\\ekino\\admin\\templates\\sala.tpl',
      1 => 1338239724,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '157994fc3ebbc87b899-98634808',
  'function' => 
  array (
    'tabela_sala' => 
    array (
      'parameter' => 
      array (
        'sala_kolumna' => 1,
      ),
      'compiled' => '',
    ),
  ),
  'variables' => 
  array (
    's2' => 0,
    'sala_kolumna' => 0,
    'sala' => 0,
    'w' => 0,
    'numer' => 0,
    'sale' => 0,
  ),
  'has_nocache_code' => 0,
  'version' => 'Smarty-3.1.8',
  'unifunc' => 'content_4fc3ebbcbdd855_80986409',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_4fc3ebbcbdd855_80986409')) {function content_4fc3ebbcbdd855_80986409($_smarty_tpl) {?><?php if (isset($_smarty_tpl->tpl_vars['s2']->value)&&$_smarty_tpl->tpl_vars['s2']->value=='dodaj'){?>

	<script>
		function isInt(value){ 
		   return !isNaN(parseInt(value)*1);
		}
		$(document).ready(function(){
			$("input#dodaj").click(function(){
				if($("input[name='kolumna']").val() == "" || $("input[name='kolumna']").val() == '0'){
					$(".komunikat").html("Kolumna > nie moze byc pusty lub zero");
				}else if(!isInt($("input[name='kolumna']").val())){
					$(".komunikat").html("Kolumna > zly format");
				}else if($("input[name='wiersz']").val() == "" || $("input[name='wiersz']").val() == '0'){
					$(".komunikat").html("Wiersz > nie moze byc pusty lub zero");
				}else if(!isInt($("input[name='wiersz']").val())){
					$(".komunikat").html("Wiersz > zly format");
				}else{
					$(".komunikat").html("");
				}
				
				if($(".komunikat").html() == ""){
					$("#wstep").hide();
					$("#bg-alpha").hide();
					$("#manager-sala table").html("");
					var z=1;
					for(x=0; x<parseInt($("input[name='kolumna']").val()); x++){
					
						$("<tr></tr>").prependTo("#manager-sala table");
						for(y=0; y<parseInt($("input[name='wiersz']").val()); y++){
							$("<td><div class='opened'><b>"+z+"</b><input type='hidden' name='"+z+"' value='o' /></div></td>").appendTo("#manager-sala table tr:eq(0)");
							z++;
						}
					}
					$("input[name='sala_kolumna']").val($("input[name='kolumna']").val());
					$("input[name='sala_wiersz']").val($("input[name='wiersz']").val());
					

					$( "#tablica_sala tr td div" ).droppable({
						drop: function( event, ui ) {
							k='';
							if(ui.draggable.hasClass("closed")){
								$(this).removeAttr("class");
								$(this).addClass("closed");
								k='c';
							}							
							if(ui.draggable.hasClass("opened")){
								$(this).removeAttr("class");
								$(this).addClass("opened");
								k='o';
							}
							$("input",this).val(k);
						}
					});
				
				}

			});

			$( "div.move" ).draggable({helper: "clone"});
		});
	
	</script>
	<style>	
		#manager-sala td{
			height:30px;
			width:25px;
		}
		.opened{
			background-color:#D6E01B;
			width:25px;
			height:30px;
			line-height:35px;
			text-align:center;
		}
		.closed{
			background-color:#DEDEDE;
			width:25px;
			height:35px;
			line-height:35px;
			text-align:center;
		}
		#tablica_sala{
			float:left;
			border-right:1px solid #eee;
			margin-right:10px;
		}
		#tasklist{
			float:left;
		}
		.move{
			cursor:move;
		}
	</style>

	<center>
		<div id="bg-alpha" style="position:absolute; width:100%; height:100%; left:0; top:0; background-image:url(./images/blackpng.png);"></div>
		<div style="display:inline-block; width:400px;">
			<div id="wstep" style="width:400px; position:absolute; top:50px; heigth:200px; background-color:white; border:1px solid #ccc;">
				<h1>Dodaj sala</h1>
				<div class="komunikat" style='color:red;'></div>
				<br />
				<div style='clear:left;'><div style='float:left; width:200px;'>Liczba kolumn:</div><div><input type='text' name='kolumna' /></div></div>
				<div style='clear:left;'><div style='float:left; width:200px;'>Liczba wiersz:</div><div><input type='text' name='wiersz' /></div></div>
				<br />
				<input type="button" id="anuluj" value="Anuluj" name="submit" onClick="parent.location='./sala.php'" /><input type="submit" id="dodaj" value="Dodaj" name="submit" />
				
				<br /><br />
			</div>
		</div>
	</center>
	<div id="manager-sala">
		<h1>Zbuduj!</h1>
		<center>
		<div style="display:inline-block;">
			<form action="./sala.php?action=dodaj_sala" method="post">
				<input type="hidden" name="sala_kolumna" />
				<input type="hidden" name="sala_wiersz" />
				<table cellpadding="5" cellspacing="5" id="tablica_sala" style="min-height:200px; min-width:200px; border:1px solid #eee;">
					
				</table>
				
				<div id="tasklist">
					<div>
						<span><b>Przeciągaj je, <br /> by ułożyć je w tabelę.</b></span><br /><br />
						<div class="opened move"></div> - krzeslo
						<br />
						<div class="closed move" title="uszkodzone lub brak krzesla"></div> - droga
					</div>
				</div>
				<div style='clear:both;'>
				
				Numer :<input type="text" value="" name="numer" /> <br />
				</div>
				<div style="clear:both; margin-top:10px; margin-bottom:10px;"><input type="submit" value='Zapisz'/></div>
			</form>
		</div>
		</center>
	</div>
<?php }elseif(isset($_smarty_tpl->tpl_vars['s2']->value)&&$_smarty_tpl->tpl_vars['s2']->value=='edytuj_sala'){?>
	
		<script>
			function isInt(value){ 
			   return !isNaN(parseInt(value)*1);
			}
			$(document).ready(function(){
				$("input#dodaj").click(function(){
					if($("input[name='kolumna']").val() == "" || $("input[name='kolumna']").val() == '0'){
						$(".komunikat").html("Kolumna > nie moze byc pusty lub zero");
					}else if(!isInt($("input[name='kolumna']").val())){
						$(".komunikat").html("Kolumna > zly format");
					}else if($("input[name='wiersz']").val() == "" || $("input[name='wiersz']").val() == '0'){
						$(".komunikat").html("Wiersz > nie moze byc pusty lub zero");
					}else if(!isInt($("input[name='wiersz']").val())){
						$(".komunikat").html("Wiersz > zly format");
					}else{
						$(".komunikat").html("");
					}
					
					if($(".komunikat").html() == ""){
						$("#wstep").hide();
						$("#bg-alpha").hide();
						$("#manager-sala table").html("");
						var z=1;
						for(x=0; x<parseInt($("input[name='kolumna']").val()); x++){
						
							$("<tr></tr>").prependTo("#manager-sala table");
							for(y=0; y<parseInt($("input[name='wiersz']").val()); y++){
								$("<td><div class='opened'><b>"+z+"</b><input type='hidden' name='"+z+"' value='o' /></div></td>").appendTo("#manager-sala table tr:eq(0)");
								z++;
							}
						}
						$("input[name='sala_kolumna']").val($("input[name='kolumna']").val());
						$("input[name='sala_wiersz']").val($("input[name='wiersz']").val());
						

						$( "#tablica_sala tr td div" ).droppable({
							drop: function( event, ui ) {
								k='';
								if(ui.draggable.hasClass("closed")){
									$(this).removeAttr("class");
									$(this).addClass("closed");
									k='c';
								}							
								if(ui.draggable.hasClass("opened")){
									$(this).removeAttr("class");
									$(this).addClass("opened");
									k='o';
								}
								$("input",this).val(k);
							}
						});
					
					}

				});

				$( "div.move" ).draggable({helper: "clone"});
			});
		
		</script>
		<style>	
			#manager-sala td{
				height:30px;
				width:25px;
			}
			.opened{
				background-color:#D6E01B;
				width:25px;
				height:30px;
				line-height:35px;
				text-align:center;
			}
			.closed{
				background-color:#DEDEDE;
				width:25px;
				height:35px;
				line-height:35px;
				text-align:center;
			}
			#tablica_sala{
				float:left;
				border-right:1px solid #eee;
				margin-right:10px;
			}
			#tasklist{
				float:left;
			}
			.move{
				cursor:move;
			}
		</style>
	
	
	<?php if (!function_exists('smarty_template_function_tabela_sala')) {
    function smarty_template_function_tabela_sala($_smarty_tpl,$params) {
    $saved_tpl_vars = $_smarty_tpl->tpl_vars;
    foreach ($_smarty_tpl->smarty->template_functions['tabela_sala']['parameter'] as $key => $value) {$_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);};
    foreach ($params as $key => $value) {$_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);}?>
		<?php if ($_smarty_tpl->tpl_vars['sala_kolumna']->value!=$_smarty_tpl->tpl_vars['sala']->value['tablica']['sala_kolumna']){?>
			<?php smarty_template_function_tabela_sala($_smarty_tpl,array('sala_kolumna'=>($_smarty_tpl->tpl_vars['sala_kolumna']->value+1)));?>

			<tr>
				<?php $_smarty_tpl->tpl_vars['w'] = new Smarty_Variable;$_smarty_tpl->tpl_vars['w']->step = 1;$_smarty_tpl->tpl_vars['w']->total = (int)ceil(($_smarty_tpl->tpl_vars['w']->step > 0 ? $_smarty_tpl->tpl_vars['sala']->value['tablica']['sala_wiersz']+1 - (1) : 1-($_smarty_tpl->tpl_vars['sala']->value['tablica']['sala_wiersz'])+1)/abs($_smarty_tpl->tpl_vars['w']->step));
if ($_smarty_tpl->tpl_vars['w']->total > 0){
for ($_smarty_tpl->tpl_vars['w']->value = 1, $_smarty_tpl->tpl_vars['w']->iteration = 1;$_smarty_tpl->tpl_vars['w']->iteration <= $_smarty_tpl->tpl_vars['w']->total;$_smarty_tpl->tpl_vars['w']->value += $_smarty_tpl->tpl_vars['w']->step, $_smarty_tpl->tpl_vars['w']->iteration++){
$_smarty_tpl->tpl_vars['w']->first = $_smarty_tpl->tpl_vars['w']->iteration == 1;$_smarty_tpl->tpl_vars['w']->last = $_smarty_tpl->tpl_vars['w']->iteration == $_smarty_tpl->tpl_vars['w']->total;?>
					<?php $_smarty_tpl->tpl_vars['numer'] = new Smarty_variable(($_smarty_tpl->tpl_vars['sala_kolumna']->value-1)*$_smarty_tpl->tpl_vars['sala']->value['tablica']['sala_wiersz']+$_smarty_tpl->tpl_vars['w']->value, null, 0);?>
					<td><div class='<?php if ($_smarty_tpl->tpl_vars['sala']->value["tablica"][$_smarty_tpl->tpl_vars['numer']->value]=="o"){?>opened<?php }else{ ?>closed<?php }?>'><b><?php echo $_smarty_tpl->tpl_vars['numer']->value;?>
</b><input type='hidden' name='<?php echo $_smarty_tpl->tpl_vars['numer']->value;?>
' value='<?php if ($_smarty_tpl->tpl_vars['sala']->value["tablica"][$_smarty_tpl->tpl_vars['numer']->value]=="o"){?>o<?php }else{ ?>c<?php }?>' /></div></td>
				<?php }} ?>
			</tr>
		<?php }?>
	<?php $_smarty_tpl->tpl_vars = $saved_tpl_vars;}}?>

		<div id="manager-sala">
			<h1>Zbuduj!</h1>
			<center>
			<div style="display:inline-block;">
				<form action="./sala.php?action=edytuj_sala&id=<?php echo $_smarty_tpl->tpl_vars['sala']->value['id_sala'];?>
" method="post">
					<input type="hidden" name="sala_kolumna" />
					<input type="hidden" name="sala_wiersz" />
					<table cellpadding="5" cellspacing="5" id="tablica_sala" style="min-height:200px; min-width:200px; border:1px solid #eee;">
						<?php smarty_template_function_tabela_sala($_smarty_tpl,array());?>

					</table>
					
					<div id="tasklist">
						<div>
							<span><b>Przeciągaj je, <br /> by ułożyć je w tabelę.</b></span><br /><br />
							<div class="opened move"></div> - krzeslo
							<br />
							<div class="closed move" title="uszkodzone lub brak krzesla"></div> - droga
						</div>
					</div>
					<div style='clear:both;'>
					
					Numer :<input type="text" value="<?php echo $_smarty_tpl->tpl_vars['sala']->value['numer'];?>
" name="numer" /> <br />
					</div>
					<div style="clear:both; margin-top:10px; margin-bottom:10px;"><input type="submit" value='Zapisz'/></div>
				</form>
			</div>
			</center>
		</div>
<?php }else{ ?>
	<a href="./sala.php?action=dodaj_sala" >Dodaj sala</a>
	<table>
	<?php if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['k'])) unset($_smarty_tpl->tpl_vars['smarty']->value['section']['k']);
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['loop'] = is_array($_loop=$_smarty_tpl->tpl_vars['sale']->value) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['name'] = 'k';
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['show'] = true;
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['loop'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['step'] = 1;
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['loop']-1;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['show']) {
    $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['loop'];
    if ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['total'] == 0)
        $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['show'] = false;
} else
    $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['total'] = 0;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['show']):

            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration'] = 1;
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['total'];
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration']++):
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['first']      = ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration'] == 1);
$_smarty_tpl->tpl_vars['smarty']->value['section']['k']['last']       = ($_smarty_tpl->tpl_vars['smarty']->value['section']['k']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['k']['total']);
?>
		<tr><td>Sala #<?php echo $_smarty_tpl->tpl_vars['sale']->value[$_smarty_tpl->getVariable('smarty')->value['section']['k']['index']]['numer'];?>
</td><td><a href='./sala.php?action=edytuj_sala&id=<?php echo $_smarty_tpl->tpl_vars['sale']->value[$_smarty_tpl->getVariable('smarty')->value['section']['k']['index']]['id_sala'];?>
'>Edytuj</a> <a href='./sala.php?action=usun_sala&id=<?php echo $_smarty_tpl->tpl_vars['sale']->value[$_smarty_tpl->getVariable('smarty')->value['section']['k']['index']]['id_sala'];?>
'>Usuń</a></td></tr>
	<?php endfor; endif; ?>
	</table>
<?php }?><?php }} ?>